<%@page import="helpers.UrlHelper"%>
<%@page import="com.google.appengine.api.images.ImagesServiceFactory"%>
<%@page import="com.google.appengine.api.images.ImagesService"%>
<%@page import="com.google.appengine.api.blobstore.BlobKey"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreService"%>
<%@page import="models.UserModel"%>
<%@page import="models.SiteConfigModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	SiteConfigModel siteConfig = (SiteConfigModel) request.getAttribute("config");
	UserModel user = (UserModel) request.getAttribute("user_logged_in");
	BlobKey blobKey = new BlobKey(siteConfig.getLogo());
	
	ImagesService imagesService = ImagesServiceFactory.getImagesService();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<%=siteConfig.getHttpCharacterSet().toUpperCase()%>">
<meta name="http://localhost:8888/validation" content="0a137b375cc3881a70e186ce2172c8d1" />
<meta name="description" content="<%=request.getParameter("description").replaceAll("[\"\']+", "")%>" >
<meta name="Keywords" content="<%=request.getParameter("keywords").replaceAll("[\"\']+", "")%>" >
<link href="/css/style.css" type="text/css" rel="stylesheet">
<link rel="alternate" type="application/rss+xml" title="<%=UrlHelper.getServerUrl(request) %> - RSS" href="http://<%=UrlHelper.getServerUrl(request) %>/rss" />
<meta property="og:site_name" content="<%=request.getParameter("ogsite_name") %>" >
<meta property="og:title" content="<%=request.getParameter("ogtitle").replaceAll("[\"\']+", "")%>" >
<meta property="og:url" content="<%=request.getParameter("ogurl")%>" >
<meta property="og:image" content="<%=request.getParameter("ogimage")%>" >
<meta property="og:description" content="<%=request.getParameter("ogdescription") %>" >
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/jquery.timeago.js"></script>
<script type="text/javascript" src="/js/general.js"></script>
<title><%=request.getParameter("title")%></title>
</head>
<body>
	<div id="toTop" class="scrollTop"></div>
	<!-- div#header - 1 -->
	<div id="header" class="page-container">
		<header>
			<h1 class="logo">
				<a href="/home">
				<% if (siteConfig.getLogo() != null && !siteConfig.getLogo().isEmpty()) {%>
					<img width="62" height="27" src="<%//=imagesService.getServingUrl(blobKey) %>=s62">
				<% } %>	
				</a>
			</h1>
			<ul id="page-nav">
				<li><a href="/home">Popular</a></li>
				<li><a href="/hot-news">Hot news</a></li>
			</ul>
			<ul id="site-nav">
				<% if (user != null) { %>
				<li class="profile">
					<a href="javascript: return false;"><%=user.getUsername() %></a>
					<div id="site-nav-profile" class="profilePopup">
						<div class="profile-triangleUp"></div>
						<div class="profile-form">
							<a href="/profile">Profile</a><br />
							<a href="/submit-news">Submit a news</a><br />
							<a href="/profile/list-news">List news submited</a>
						</div>
					</div>
				</li>
				<li><a href="/logout">Logout</a></li>
				<% } else { %>
				<li id="sign-in" class="userLogin">
					<a href="/login">Sign In</a>
					<div id="site-nav-signin" class="loginPopup">
						<div class="signin-triangleUp"></div>
						<div class="login-form">
							<h2>Login</h2>
							<form method="post" action="">
		                    	<div>
		                         	<label class="">
										Email:
		                                <input type="text" name="email"/>
		                                <div class="triangleUp"></div>
		                                <div class="errorMessage">
		                                	Email not valid.
											<br />	
											Please enter " <strong>Email</strong> " .
		                                </div>
		                            </label>
								</div>
		                        <div>
		                        	<label class="">
		                            	Password:
		                                <input type="password" name="password" />
		                                <div class="triangleUp"></div>
		                                <div class="errorMessage">Please enter " <strong>Email</strong> " .</div>
		                            </label>
		                        </div>
		                        <div>
		                        	<label>
		                            	<input type="checkbox" />
		                                Remeber login
		                            </label>                                                	
		                        </div>
		                        <div class="clearafter">
		                        	<button type="submit" class="left button orange">Login</button>
		                            <div class="left forgotPassword">
		                            	[<a href="#">Forgot password?</a>]
		                            </div>
		                        </div>
		                    </form>
		                </div>
	                </div>
				</li>
				<li><a href="/register">Register</a></li>
				<% } %>
			</ul>
		</header>
	</div>
	<!-- end div#header - 1 -->
	
	<!-- div#container - 1  -->
	<div id="container" class="page-container">
		<div id="main-content">